package cn.virens.database.serviceimpl.sys;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;

import cn.virens.database.common.BaseServiceImpl;
import cn.virens.database.common.ExampleWrapper;
import cn.virens.database.mysql.mapper.sys.SysMessageMapper;
import cn.virens.database.mysql.model.sys.SysMessage;
import cn.virens.database.service.sys.SysMessageService;

/**
 * 消息管理 - sys_message
 *
 * @author Virens
 * @since  2018-08-25 15:38:28
 */
@Service
public class SysMessageServiceImpl extends BaseServiceImpl<SysMessageMapper, SysMessage> implements SysMessageService {

	public SysMessageServiceImpl() {
		super(SysMessage.class);
	}

	@Override
	public List<? extends SysMessage> selectAll(Map<String, Object> param) {
		ExampleWrapper example = ExampleWrapper.of(clazz);
		example.excludeProperties("content");
		example.or((criteria) -> {
			criteria.andEqualTo("type", criteriaEqual(param, "type"));
			criteria.andEqualTo("state", criteriaEqual(param, "state"));
			criteria.andEqualTo("receive", criteriaEqual(param, "receive"));

			criteria.andLike("abstr", criteriaLike(param, "abstr"));
			criteria.andLike("title", criteriaLike(param, "title"));
			criteria.andLike("sender", criteriaLike(param, "sender"));
		});

		return mBaseMapper.selectByExample(example);
	}
}
